let index = new Vue({
    el: "#index",
    data: {},
    mounted: function () {
        let state = this.getQueryString("state");
        window.gc();
        if (state == "openFail") {
            this.notify("warning", "请检查网络!!!");
        }
    },
    methods: {
        getQueryString(name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            let r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return unescape(r[2]);
            }
            return null;
        },
        notify(type, msg, duration = 1000) {
            let dom = document.querySelector(".el-notification__icon");
            if (!dom) {
                this.$notify({
                    type: type,
                    message: msg,
                    duration: duration,
                });
            }
        },
        send(data) {
            return window.electronAPI.sendMessage(data);
        },
        open(url) {
            let data = {
                cmd: "open",
                type: "main",
                url: url,
            };
            this.send(data);
        },
    },
});
